package com.mk.cloud.common.util.pay;

import org.osgl.util.S;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by liuys on 2017/2/6.
 */
public enum BankCodeEnum {
    ABC("农业银行", "ABC"),
    BOC("中国银行", "BOC"),
    CCB("建设银行", "CCB"),
    CEB("光大银行", "CEB"),
    CIB("兴业银行", "CIB"),
    CITIC("中信银行", "CITIC"),
    CMB("招商银行", "CMB"),
    CMBC("民生银行", "CMBC"),
    COMM("交通银行", "COMM"),
    ICBC("工商银行", "ICBC"),
    PINGANBANK("平安银行", "PINGANBANK"),
    PSBC("邮储银行", "PSBC"),
    SPDB("浦发银行", "SPDB"),
    CQCB("重庆银行", "CQCB"),
    ZHESHANGB("浙商银行", "ZHESHANGB"),
    CQRCB("重庆农村商业银行", "CQRCB"),
    CGB("广发银行", "CGB");

    private final String name;
    private final String code;

    BankCodeEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    // 普通方法
    public static String getBankCode(String bankName) {
        for (BankCodeEnum c : BankCodeEnum.values()) {
            if (S.eq(c.getName(), bankName)) {
                return c.code;
            }
        }
        return null;
    }


    /**
     * 获取所有银行信息
     *
     * @param type null: key为code   1:key为name
     * @return
     */
    public static Map<String, Object> getBankList(String type) {
        if (type == null) {
            Map<String, Object> map = new HashMap<String, Object>();
            for (BankCodeEnum c : BankCodeEnum.values()) {
                map.put(c.code, c.name);
            }
            return map;
        } else if ("1".equals(type)) {
            Map<String, Object> map = new HashMap<String, Object>();
            for (BankCodeEnum c : BankCodeEnum.values()) {
                map.put(c.name, c.name);
            }
            return map;
        } else {
            return null;
        }
    }

    // get 方法
    public String getName() {
        return name;
    }

    public String getBankCode() {
        return this.code;
    }
}
